import 'dart:collection';

import 'package:dio/dio.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
import 'package:cookie_jar/cookie_jar.dart';

///暂时废弃，cookie管理与缓存
class CacheObject {
  Response response;
  int timeStamp;

  CacheObject(this.response) : timeStamp = DateTime.now().microsecondsSinceEpoch;

  @override
  bool operator ==(Object other) {
    return response.hashCode == other.hashCode;
  }

  @override
  int get hashCode => response.realUri.hashCode;
}

class NetCacheInterceptor extends Interceptor{
  static const bool CACHE_ENABLE = false;


  //保证迭代器顺序跟对象插入时间顺序一致，用LinkedHashMap
  var cache = LinkedHashMap<String,CacheObject>();

  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler) async{
    if(!CACHE_ENABLE) {};

    //refresh标记是否缓存
    bool refresh = options.extra["refresh"] == true;

    //是否磁盘缓存
    bool cacheDisk = options.extra["cacheDisk"] == true;

  }
}